﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeometryMod.Models
{
    public struct Vector3
    {
        public double X, Y, Z;

        public Vector3(double x, double y, double z)
        {
            X = x; Y = y; Z = z;
        }




        public static Vector3 Cross(Vector3 a, Vector3 b)
            => new(
                a.Y * b.Z - a.Z * b.Y,
                a.Z * b.X - a.X * b.Z,
                a.X * b.Y - a.Y * b.X
            );

        public static double Dot(Vector3 a, Vector3 b)=> a.X * b.X + a.Y * b.Y + a.Z * b.Z;
        public static Vector3 operator +(Vector3 a, Vector3 b) => new(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
        public static Vector3 operator *(Vector3 v, double scalar) => new(v.X * scalar, v.Y * scalar, v.Z * scalar);
        public static Vector3 operator -(Vector3 a, Vector3 b) => new(a.X - b.X, a.Y - b.Y, a.Z - b.Z);

        public static Vector3 ToUnitVector(Vector3 v)
        {
            var allL = v.X * v.X + v.Y *v.Y + v.Z * v.Z;


            var delta = Math.Sqrt(allL);
            return new Vector3(v.X/delta, v.Y/delta, v.Z/delta);
        }

    }
}
